<?php 
namespace app\dboard\logic;
use think\Db;
use think\facade\Session;
class Appointing extends Base
{

	function __construct()
	{
	}

	public function create($param)
	{
		$sid = isset($param['sid']) ? intval($param['sid']):0;
		$phone = isset($param['phone']) ? trim($param['phone']):'';
		$content= isset($param['content']) ? trim($param['content']):'';
   if (!$sid || !$phone || !$content) {
      $this->res_data['Msg'] = "缺少必填信息";
      return $this->res_data;
    }
		$store= Db::name('store')->where([['id','=',$sid]])->find();
		if (!$store) {
			$this->res_data['Msg'] = "无此门店";
			return $this->res_data;
		}
    $data['sid'] =$sid;
    $data['phone'] =$phone;
    $data['content'] =$content;
    $tdata = Db::name('appointing')->insertGetId($data);
    if(!$tdata) {
        $this->res_data['Msg'] = '添加教师失败';
        return $this->res_data;
    }
    $this->res_data['Msg'] = '成功';
    $this->res_data['Code'] = 0;
    return $this->printResult($this->res_data);
	}
  public function del($param)
  {
    $aid = isset($param['aid']) ? intval($param['aid']):0;
    $sid = isset($param['sid']) ? intval($param['sid']):0;
    if (!$aid || !$sid) {
      $this->res_data['Msg'] = "无必要参数";
      return $this->res_data;
    }
    $da = Db::name('appointing')->where([['id','=',$aid],['sid','=',$sid]])->delete();
    if (!$da) {
      $this->res_data['Msg'] = "删除错误";
      return $this->res_data;
    }
    $this->res_data['Msg'] = '成功';
    $this->res_data['Code'] = 0;
    return $this->printResult($this->res_data);
  }
}

?>
